﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;

public partial class MyShoppingCart : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //For testing purposes, incase we come straight to shopping cart
            if (Session["CT_ID"] == null)
            {
                Random random = new Random();
                int test;
                test = random.Next(0, 9999999);
                Session["CT_ID"] = test;
            }
            CTIDLabel.Text = Session["CT_ID"].ToString(); //Set cart ID label to session ID
        }
    }

    protected void Get_Rows(object sender, SqlDataSourceStatusEventArgs e)
    {
        if (e.AffectedRows == 0) //If query returns no rows, show the empty cart message
            emptyCartMessage.Visible = true;
    }

    double TotalAmount = 0.00;

    protected double Get_Amount(object price, object quantity)
    {
        double amount = 0;
        amount = Convert.ToDouble(price.ToString()) * Convert.ToDouble(quantity.ToString());
        TotalAmount += amount;
        return amount;
    }

    protected double Get_Shipping()
    {
        double shipping = TotalAmount *.10;
        TotalAmount += shipping;
        return shipping;
    }

    protected double Get_Order_Total()
    {
        return TotalAmount;
    }

    protected void Submit_Form(Object sender, EventArgs args)
    {
        Response.Redirect("SalesOrder.aspx");   //Go to Sales Order Page on Checkout
    }





}